



drag = 0
h = 0
while names:
    try:
        drag += 100
        for name in names:
            time.sleep(2)
            lis = self.driver.find_elements_by_css_selector("[class = 'next-overlay-wrapper opened'] li")
            for index, li in enumerate(lis):
                text = li.text
                match = re.search(name, text)
                if match:
                    self.driver.find_element_by_css_selector("[class = 'next-overlay-wrapper opened'] li:nth-child({})".format(index+1)).click()
            print(name)
            names.remove(name)
            time.sleep(1)
    except:
        cssselector = '[class="next-overlay-wrapper opened"]>div'
        js = "var q=document.querySelector('{}').scrollTop = {}".format(cssselector, drag) # getElementsByClassName表示获取class='main'的元素列表，0表示第一个，所以使用的时候要加索引
        self.driver.execute_script(js)
        time.sleep(1)
        h += 1
    if h > 8:
        break